<?php if (!defined('BASEPATH'))exit('No direct script access allowed');
class Statistics extends MY_Controller{
    function __construct() {
        parent::__construct();
        $this->load->model('../../Back/app/models/statistics_model');
    }

    function index(){
        $dic_value = $_GET['plat'];
        $start_date = isset($_GET['time_start'])?trim($_GET['time_start']):date('Y/m/d');
        $end_date = isset($_GET['time_end'])?trim($_GET['time_end']):date('Y/m/d');

        $time_start = strtotime(str_replace('/','-',$start_date));
        $time_end = strtotime(str_replace('/','-',$end_date));

        $day = date('Y-m-d',time());
        $one_dic = $this->db->query("select * from tan_dictionary where type=1 and value={$dic_value}")->row_array();
        if(isset($time_start) && isset($time_end)){
            $list = $this->statistics_model->get_platreg_list($one_dic['id'],$time_start,$time_end);

        }else{
            $list[] = $this->statistics_model->get_platreg_day($one_dic['id'],$day);
        }
        $this->assign('plat', $one_dic);
        $this->assign('start_date', $start_date);
        $this->assign('end_date', $end_date);
        $this->assign('list', $list);
        $this->display('statistics/index.html');

    }
}